/*********************************************************************\
*                                                                     *
*         Jamper - Java XML mapper (visual XSLT generator)            *
*                Copyright (C) 2005 Filip Pavlovic                    *
*                    sqba@users.sourceforge.net                       *
*                                                                     *
*  This program is free software; you can redistribute it and/or      *
*  modify it under the terms of the GNU General Public License        *
*  as published by the Free Software Foundation; either version 2     *
*  of the License, or (at your option) any later version.             *
*                                                                     *
*  This program is distributed in the hope that it will be useful,    *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
*  GNU General Public License for more details.                       *
*                                                                     *
*  You should have received a copy of the GNU General Public License  *
*  along with this program; if not, write to the Free Software        *
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston,             *
*  MA 02111-1307, USA.                                                *
*                                                                     *
\*********************************************************************/


package sqba.jamper.map.object;


import java.awt.Point;
import java.awt.Graphics;
import java.util.Collection;
import javax.swing.JMenu;
import javax.swing.JComponent;

import org.w3c.dom.Element;

//import org.w3c.dom.Element;

import sqba.jamper.map.IPropObject;
import sqba.jamper.util.PathList;


/**
 * Interface for all mapper objects:
 * tree nodes, link lines, function parameters, function output, etc.
 *
 * @author	Filip Pavlovic
 * @version	1.0
 */
public interface IMapObject extends IPropObject
{
	/** Maximum distance in pixels (for hitTest()). */
	public static final double	_max_dist = 2.0;

	/**
	 * Returns true if the object is selected.
	 *
	 * @return true if the object is selected.
	 */
	abstract boolean isSelected();

	/**
	 * Selects or deselects object.
	 *
	 * @param sel if true then the object is selected.
	 */
	abstract void select( boolean sel );

	/**
	 * Draws the object.
	 *
	 * @param g Graphics
	 * @param parent JComponent
	 */
	abstract void draw( Graphics g, JComponent parent );

	/**
	 * Returns true if the object contains the point pt.
	 *
	 * @param pt Point
	 * 
	 * @return true if the object contains the point pt.
	 */
	abstract boolean hitTest( Point pt );

	/**
	 * Returns String object containing the class name (type?).
	 * 
	 * @return String.
	 */
	abstract String getName();

	/**
	 * Returns parent object or null.
	 * 
	 * @return parent object or null.
	 */
	abstract IMapObject getParentObject();

	/**
	 * Returns the collection of child objects or null.
	 * 
	 * @return the collection of child objects or null.
	 */
	abstract Collection getChildObjects();
	
	abstract IMapObject getChild(String name);

	/**
	 * Like hitTest, this function returns a pointer to a child Linkable
	 * object that contains the point pt, this pointer if the point is
	 * inside the object or null if no objects found.
	 *
	 * @param pt Point
	 *
	 * @return child MapObject or null
	 */
	abstract IMapObject getChildAt(Point pt);
	
	abstract void removeChild(IMapObject obj);
	
	//abstract void removeLinks();

	abstract JMenu getMenu();
//	abstract void setMenu(JMenu menu);
	
//	abstract void save(Element parent);
//	abstract void load(Element parent);
	
//	abstract String getTypeName();
	
	abstract String getDisplayName();
	
	abstract Point getOrigin();
	
	abstract void setName(String name);
	
	abstract String getFullPath();

	abstract int getID();
	abstract void setID(int ID);
	
	abstract String getUniqueName();


	abstract Element save(Element node);
	abstract boolean load(Element node);
	
	abstract Element render(PathList context, Element parent);
	abstract Element renderDeclaration(PathList context, Element parent);
	
	abstract void move(int x, int y);
	
	abstract IMapObject copy();
}
